module.exports = {
  publicPath: './',
  outputDir: 'dist',
  assetsDir: 'static',
  productionSourceMap: false,
  chainWebpack: config => {
    config.module
      .rule('audio')
      .test(/\.(wav|mp3)$/)
      .use('file-loader')
      .loader('file-loader')
      .options({
        name: 'static/audio/[name].[ext]'
      })
      .end();

    // 复制托盘图标到dist目录
    config.plugin('copy')
      .use(require('copy-webpack-plugin'), [[
        {
          from: 'public/static',
          to: 'static'
        }
      ]]);
  },
  devServer: {
    port: 8081,
    proxy: {
      '/api': {
        target: 'http://localhost:8080',
        changeOrigin: true,
        pathRewrite: {
          '^/api': '/api'
        }
      },
      '/uploads': {
        target: 'http://localhost:8080',
        changeOrigin: true
      },
      '/ws': {
        target: 'ws://localhost:8080',
        ws: true,
        changeOrigin: true
      }
    }
  }
}; 